package com.yh.correct.service.impl;

import java.util.List;
import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yh.correct.dao.IReportMapper;
import com.yh.correct.model.Page;
import com.yh.correct.model.Report;
import com.yh.correct.service.IReportService;

/**
 * @author Administrator
 * @注释 :     思想汇报情况服务层实现类
 */
@Service
public class ReportServiceImpl implements IReportService {

    private static Logger logger = LogManager.getLogger(ReportServiceImpl.class);

    @Autowired
    private IReportMapper ireportMapper;

    /**
     * @author Administrator
     * @注释 : 增加服刑人员思想汇报
     */
    @Override
    public int addReport(Report report) throws Exception {
        // TODO Auto-generated method stub
        logger.debug("增加服刑人员思想汇报+IReportServiceImpl");
        return ireportMapper.addReport(report);
    }

    /**
     * @author Administrator
     * @注释 : 删除服刑人员思想汇报
     */
    @Override
    public int delReport(int id) throws Exception {
        // TODO Auto-generated method stub
        logger.debug("删除服刑人员思想汇报+IReportServiceImpl");
        return ireportMapper.delReport(id);
    }
    @Override
    public int deleteBatch(List<Integer> list) throws Exception {
        return ireportMapper.deleteBatch(list);
    }

    /**
     * @author Administrator
     * @注释 : 修改服刑人员思想汇报
     */

    @Override
    public int editReport(Report report) throws Exception {
        // TODO Auto-generated method stub
        logger.debug("修改服刑人员思想汇报+IReportServiceImpl");
        return ireportMapper.editReport(report);
    }

    /**
     * @author Administrator
     * @注释 : 模糊查询服刑人员思想汇报
     */

    @Override
    public Page getListReport(Map<String, Object> Report) throws Exception {
        // TODO Auto-generated method stub
        Page page = new Page();
        page.setTotalNum(ireportMapper.getLikeReportCount(Report));
        int pageSize = Integer.parseInt(String.valueOf(Report.get("pageSize")));
        page.setPageSize(pageSize);
        int curPageNum = Integer.parseInt(String.valueOf(Report.get("pageNum")));
        page.setCurPageNum(curPageNum);
        page.setTotalPage(page.getTotalNum() / pageSize + (page.getTotalNum() % pageSize == 0 ? 0 : 1));
        page.setResult(ireportMapper.getListReport(Report));
        logger.debug("模糊查询监管等级 + IreportServiceImpl");
        return page;

    }

    @Override
    public List<Map<String, Object>> getAllReport() throws Exception {
        // TODO Auto-generated method stub
        return ireportMapper.getAllReport();
    }

    @Override
    public Map<String, Object> getIdReport(int id) throws Exception {
        // TODO Auto-generated method stub
        return ireportMapper.getIdReport(id);
    }

}
